/**
 * @(#) ContractMediator.as
 *
 * @date		2009. 03. 11.
 * @version		1.0
 * @author		Park, JuneHo
 * @description	공지사항 - Mediator
 * 				공지사항 Presentation Logic을 관리 
 */
package com.skt.common_hr.contract.view
{
	import com.skt.common_hr.common.Variables;
	import com.skt.common_hr.common.components.CommonAlert;
	import com.skt.common_hr.common.puremvc.OverViewMediator;
	import com.skt.common_hr.contract.ContractFacade;
	import com.skt.common_hr.contract.model.ContractProxy;
	import com.skt.common_hr.contract.view.components.ContractOverView;
	
	import org.puremvc.as3.multicore.interfaces.INotification;
	

	public class ContractMediator extends OverViewMediator
	{
		public static const NAME:String = "ContractMediator";
		
		/**
		* 생성자
		* 
		* @param
		* @return void
		*/
        public function ContractMediator( viewComponent:Object )
        {
            super( NAME, viewComponent );
        }
 		
		/**
		* View를 초기화 한다.
		*	- View에 기본사항을 출력하고 data를 load
		* @param
		* @return void
		*/
 		override protected function activatedView():void
 		{
 			var proxy:ContractProxy = facade.retrieveProxy(ContractProxy.NAME) as ContractProxy;
 			proxy.load(Variables.myPernr);
			
 		}
 		
  		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Process MVC Messages
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		/**
		* 본 Class에서 처리해야할 Noti들을 등록한다.
		* 
		* @param
		* @return void
		*/
		override public function listNotificationInterests():Array 
		{
			return basicInterestMessages.concat( [
					ContractFacade.LOAD_CONTRACT_COMPLETE,
					ContractFacade.LOAD_CONTRACT_FAILED
					]);
		}
		

		/**
		* Noti별로 처리한다.
		* 
		* @param
		* @return void
		*/
		override public function handleNotification(note:INotification):void
		{
			super.handleNotification(note);
			switch(note.getName()) 
			{
				case ContractFacade.LOAD_CONTRACT_COMPLETE:
					view.dataProvider = (note.getBody() as ContractProxy).contractList;
					commonFacade.setStatusMessage("STATUS_LOADED_LIST", [view.dataProvider.length]);
					break;
				case ContractFacade.LOAD_CONTRACT_FAILED:
					CommonAlert.showMessage(commonFacade.bundle, "ALERT_FAILED_LOAD_LIST", null, "ALERT_TITLE_SYSTEM_ERROR");
					break;
				default:
					//trace(this.instanceID+"에서 처리 안된 Noti가 검출됨 : " + note.getBody());
					break;
			}
		}
		
		
		
		
		
		
		
		
 
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Event handler (from View, Internal or....)
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
		
		
		///////////////////////////////////////////////////////////////////////////////////////////////////
		//
		//	Utility Functions
		//
		///////////////////////////////////////////////////////////////////////////////////////////////////
        private function get view():ContractOverView
        {
            return viewComponent as ContractOverView;
        }
	}
}